import {Modal} from 'view-design'

const dialog = ({
                  title = '警告',
                  content = '此操作将无法回退,确认执行该操作?',
                  type = 'confirm',
                  okText = '确认',
                  cancelText = '取消',
                  closable = true,

                  params = {}
                }) => {
  return new Promise((resolve, reject) => {
    if (type === 'confirm') {
      Modal.confirm({
        title: title,
        content: content,
        okText,
        cancelText,
        closable,
        footerHide: true,
        maskClosable: true,
        onOk: () => {
          resolve(params);
        },
        onCancel: (err) => {
          console.log(err);
          reject(params);
        }
      })
    } else if (type === 'info') {
      Modal.info({
        title: title,
        content: content,
        onOk: () => {
          resolve(params);
        }
      })
    }
  })
}

export default dialog;
